package com.future.jdk;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

/**
 * @author chenli
 * @create 2018-09-30
 */
public class AnimalProxyHandler implements InvocationHandler {

    //代理对象
    private Object proxyied;

    public AnimalProxyHandler(Object proxyied){
        //初始化代理对象
        this.proxyied = proxyied;
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        System.out.println("代理调用前");
        Object invoke = method.invoke(proxyied, args);
        System.err.println(invoke);
        System.err.println("代理后调用");
        return invoke;
    }
}